﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SQLite;
namespace ToolsCollection.DAL
{
   public class TC_FILES
    {
        /// <summary>
        /// 查询指定ID的数据集
        /// </summary>
        /// <param name="model_Tc_Files"></param>
        /// <returns></returns>
        public DataTable GetTC_Files(ToolsCollection.MODEL.TC_FILES model_Tc_Files)
        {
            string sql = "select * from tc_files where baglist_id=" + model_Tc_Files.BagList_Id;
            return ToolsCollection.Helper.SqliteHelper.ExecuteDataSet(ToolsCollection.Helper.SqliteHelper.ConnString, new SQLiteCommand() { CommandText = sql }).Tables[0];
        }
        //删除指定ID的数据集
        /// <summary>
        /// 添加指定ID的数据集
        /// </summary>
        /// <param name="list_Tc_Files"></param>
        public void Add_TC_Files(List<ToolsCollection.MODEL.TC_FILES> list_Tc_Files)
        {
            list_Tc_Files.ForEach(lt =>
            {
                string sql = string.Concat("insert into tc_files (files_id,baglist_id,file_path) values(null,", lt.BagList_Id, ",'", lt.File_Path, "')");
                ToolsCollection.Helper.SqliteHelper.ExecuteNonQuery(ToolsCollection.Helper.SqliteHelper.ConnString, new SQLiteCommand { CommandText = sql });
            });
        }
        /// <summary>
        /// 删除指定包文件列表
        /// </summary>
        /// <param name="mode_Tc_Files"></param>
        public void Del_TC_Files(int bagList_Id)
        {
            string sql = "delete from tc_files where baglist_id=" + bagList_Id;
            ToolsCollection.Helper.SqliteHelper.ExecuteNonQuery(ToolsCollection.Helper.SqliteHelper.ConnString, new SQLiteCommand { CommandText = sql });
        }
    }
}
